package com.muyu.product.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.model.ProjectAddModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.product.domain.req.ProjectInfoQueryReq;
import com.muyu.product.domain.req.ProjectInfoSaveReq;
import com.muyu.product.domain.req.ProjectInfoEditReq;
import com.muyu.common.core.web.domain.BaseEntity;

import java.util.List;

/**
 * 商品信息对象 project_info
 *
 * @author DongZeLiang
 * @date 2024-02-27
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("project_info")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "ProjectInfo", description = "商品信息")
public class ProjectInfo extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /** 主键 */
    @TableId(value = "id",type = IdType.AUTO)
    @ApiModelProperty(name = "主键", value = "主键")
    private Long id;

    /** 商品名称 */
    @Excel(name = "商品名称")
    @ApiModelProperty(name = "商品名称", value = "商品名称")
    private String name;

    /** 商品描述 */
    @Excel(name = "商品描述")
    @ApiModelProperty(name = "商品描述", value = "商品描述")
    private String introduction;

    /** 主类型 */
    @Excel(name = "主类型")
    @ApiModelProperty(name = "主类型", value = "主类型")
    private String mianType;

    /** 父类型 */
    @Excel(name = "父类型")
    @ApiModelProperty(name = "父类型", value = "父类型")
    private String parentType;

    /** 商品类型 */
    @Excel(name = "商品类型")
    @ApiModelProperty(name = "商品类型", value = "商品类型")
    private String type;

    /** 商品图片 */
    @Excel(name = "商品图片")
    @ApiModelProperty(name = "商品图片", value = "商品图片")
    private String image;

    /** 商品轮播图 */
    @Excel(name = "商品轮播图")
    @ApiModelProperty(name = "商品轮播图", value = "商品轮播图")
    private String carouselImages;

    /** 商品状态 */
    @Excel(name = "商品状态")
    @ApiModelProperty(name = "商品状态", value = "商品状态")
    private String status;

    /** 规格 */
    @Excel(name = "规格")
    @ApiModelProperty(name = "规格", value = "规格")
    private Long ruleId;

    /** 品牌 */
    @Excel(name = "品牌")
    @ApiModelProperty(name = "品牌", value = "品牌")
    private Long brandId;

//    private List<CategoryAttribute> categoryAttributes;
//    private List<Sku> skus;

    /**
    * 查询构造器
    */
    public static ProjectInfo queryBuild( ProjectInfoQueryReq projectInfoQueryReq){
        return ProjectInfo.builder()
                .name(projectInfoQueryReq.getName())
                .introduction(projectInfoQueryReq.getIntroduction())
                .mianType(projectInfoQueryReq.getMianType())
                .parentType(projectInfoQueryReq.getParentType())
                .type(projectInfoQueryReq.getType())
                .image(projectInfoQueryReq.getImage())
                .carouselImages(projectInfoQueryReq.getCarouselImages())
                .status(projectInfoQueryReq.getStatus())
                .ruleId(projectInfoQueryReq.getRuleId())
                .brandId(projectInfoQueryReq.getBrandId())
                .build();
    }

    /**
    * 添加构造器
    */
    public static ProjectInfo saveModelBuild(ProjectAddModel projectAddModel){
        return ProjectInfo.builder()
                .name(projectAddModel.getName())
                .introduction(projectAddModel.getIntroduction())
                .mianType(projectAddModel.getMianType())
                .parentType(projectAddModel.getParentType())
                .type(projectAddModel.getType())
                .image(projectAddModel.getImage())
                .carouselImages(projectAddModel.getCarouselImages())
                .status(projectAddModel.getStatus())
                .ruleId(projectAddModel.getRuleId())
                .brandId(projectAddModel.getBrandId())
                .build();
    }

    /**
    * 修改构造器
    */
    public static ProjectInfo editBuild(Long id, ProjectInfoEditReq projectInfoEditReq){
        return ProjectInfo.builder()
            .id(id)
                .name(projectInfoEditReq.getName())
                .introduction(projectInfoEditReq.getIntroduction())
                .mianType(projectInfoEditReq.getMianType())
                .parentType(projectInfoEditReq.getParentType())
                .type(projectInfoEditReq.getType())
                .image(projectInfoEditReq.getImage())
                .carouselImages(projectInfoEditReq.getCarouselImages())
                .status(projectInfoEditReq.getStatus())
                .ruleId(projectInfoEditReq.getRuleId())
                .brandId(projectInfoEditReq.getBrandId())
                .build();
    }

}
